package com.whfc.ms.api.fvs.service.impl;

import com.whfc.common.result.ListData;
import com.whfc.fuum.service.SysDeptService;
import com.whfc.fvs.dto.FvsGroupDTO;
import com.whfc.fvs.param.FvsGroupAddParam;
import com.whfc.fvs.param.FvsGroupEditParam;
import com.whfc.fvs.service.FvsGroupService;
import com.whfc.ms.api.fvs.service.MsFvsGroupService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sun_guodong
 * @description
 * @date 2020-12-08
 */
@Service
public class MsFvsGroupServiceImpl implements MsFvsGroupService {

    @DubboReference(interfaceClass = FvsGroupService.class, version = "1.0.0")
    private FvsGroupService fvsGroupService;

    @DubboReference(interfaceClass = SysDeptService.class, version = "1.0.0")
    private SysDeptService sysDeptService;

    @Override
    public ListData<FvsGroupDTO> list(Integer deptId) {
        List<FvsGroupDTO> list = fvsGroupService.list(deptId);
        return new ListData<>(list);
    }

    @Override
    public void add(FvsGroupAddParam param) {
        fvsGroupService.add(param);
    }

    @Override
    public void edit(FvsGroupEditParam param) {
        fvsGroupService.edit(param);
    }

    @Override
    public void del(Integer groupId) {
        fvsGroupService.del(groupId);
    }

    @Override
    public ListData<FvsGroupDTO> tree(Integer deptId, String keyword) {
        List<FvsGroupDTO> list = fvsGroupService.tree(deptId, keyword);
        return new ListData<>(list);
    }

    @Override
    public ListData<FvsGroupDTO> companyList(Integer deptId) {
        List<Integer> deptIds = sysDeptService.getDescendantDeptIdList(deptId);
        List<FvsGroupDTO> list = fvsGroupService.list(deptIds);
        return new ListData<>(list);
    }
}
